import Main from './views/Main.vue';
import { resolve } from 'url';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: resolve => { require(['./views/login.vue'], resolve); }
};

export const page404 = {
    path: '/*',
    name: 'error_404',
    meta: {
        title: '404-页面不存在'
    },
    component: resolve => { require(['./views/error_page/404.vue'], resolve); }
};

export const page401 = {
    path: '/401',
    meta: {
        title: '401-权限不足'
    },
    name: 'error_401',
    component: resolve => { require(['./views/error_page/401.vue'], resolve); }
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error_500',
    component: resolve => { require(['./views/error_page/500.vue'], resolve); }
};

export const preview = {
    path: '/preview',
    name: 'preview',
    component: resolve => { require(['./views/form/article-publish/preview.vue'], resolve); }
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: resolve => { require(['./views/main_components/locking-page.vue'], resolve); }
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    component: Main,
    children: [
        { path: 'home', title: {i18n: 'home'}, name: 'home_index', component: resolve => { require(['./views/home/home.vue'], resolve); } },
        { path: 'ownspace', title: '个人中心', name: 'ownspace_index', component: resolve => { require(['./views/own-space/own-space.vue'], resolve); } },
        { path: 'order/:order_id', title: '订单详情', name: 'order_info', component: resolve => { require(['./views/advanced-router/component/order-info.vue'], resolve); } },  // 用于展示动态路由
        { path: 'shopping', title: '购物详情', name: 'shopping', component: resolve => { require(['./views/advanced-router/component/shopping-info.vue'], resolve); } },  // 用于展示带参路由
        { path: 'message', title: '消息中心', name: 'message_index', component: resolve => { require(['./views/message/message.vue'], resolve); } }
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/course',
        icon: 'ios-book',
        name: 'course',
        component: Main,
        title: '课程管理',
        children: [
            {
                path: 'class-cate',
                icon: 'ios-bookmarks',
                name: 'class-cate',
                title: '课程分类管理',
                component: resolve => {require(['./views/course/class-cate/class-cate.vue'], resolve); }
            },
            {
                path: 'video',
                icon: 'social-youtube',
                name: 'course-video-list',
                title: '视频课程列表',
                component: resolve => {require(['./views/course/video_list/index.vue'], resolve);}
            },
            {
                path: 'article',
                icon: 'ios-list',
                name: 'course-article-list',
                title: '文章课程列表',
                component: resolve => {require(['./views/course/article_list/index.vue'], resolve);}
            },
            {
                path: 'question',
                icon: 'help-circled',
                name: 'course-question',
                title: '课程提问',
                component: resolve => {require(['./views/course/question/question.vue'], resolve);}
            },
            {
                path: 'answer',
                icon: 'reply',
                name: 'course-answer',
                title: '课程回答',
                component: resolve => {require(['./views/course/answer/index.vue'], resolve);}
            },
            {
                path: 'comment',
                icon: 'chatbox',
                name: 'course-comment',
                title: '课程评论',
                component: resolve => {require(['./views/course/comment/index.vue'], resolve);}
            },
            {
                path: 'student',
                icon: 'clipboard',
                name: 'student',
                title: '学习记录',
                component: resolve => {require(['./views/course/student/student.vue'], resolve);}
            }
        
        ]
    },
    {
        path: '/test',
        icon: 'document-text',
        name: 'test',
        component: Main,
        title: '考试管理',
        children: [
            {
                path: 'config',
                icon: 'gear-b',
                name: 'test-config',
                title: '考试基本设置',
                component: resolve => {require(['./views/test/config/config.vue'], resolve); }
            },
            {
                path: 'question',
                icon: 'android-document',
                name: 'test-question',
                title: '考题管理',
                component: resolve => {require(['./views/test/question/question.vue'], resolve); }
            },
            {
                path: 'history',
                icon: 'document',
                name: 'test-history',
                title: '考试记录',
                component: resolve => {require(['./views/test/history/history.vue'], resolve); }
            },
        ]
    },
    {
        path: '/game',
        icon: 'ios-game-controller-b',
        name: 'game',
        title: '游戏管理',
        component: Main,
        children: [
            {
                path: 'config',
                icon: 'gear-b',
                name: 'game-config',
                title: '游戏设置',
                component: resolve => {require(['./views/game/config/config.vue'], resolve); }
            },
            {
                path: 'question',
                icon: 'android-document',
                name: 'game-question',
                title: '游戏试题管理',
                component: resolve => {require(['./views/game/question/question.vue'], resolve); }
            },
            {
                path: 'history',
                icon: 'document',
                name: 'game-history',
                title: '游戏记录',
                component: resolve => {require(['./views/game/history/history.vue'], resolve); }
            }
        ]
    },
    {
        path: '/organization',
        icon: 'ios-folder',
        name: 'organization',
        title: '机构管理',
        component: Main,
        children: [
            { path: 'index', icon: 'ios-folder', name: 'organ-list', title: '机构列表', component: resolve => {require(['./views/organization/list/list.vue'], resolve); } },
            { path: 'members', icon: 'person', name: 'organ-members', title: '成员列表', component: resolve => {require(['./views/organization/members/list.vue'], resolve);} }
        ]
    },
    {
        path: '/basic',
        icon: 'android-settings',
        name: 'basic',
        title: '信息中心',
        component: Main,
        children: [
            { path: 'help', icon: 'help-circled', name: 'help', title: '帮助中心', component: resolve => {require(['./views/basic_config/help/index.vue'], resolve);} },
            { path: 'feedback', icon: 'android-clipboard', name: 'feedback', title: '意见反馈', component: resolve => {require(['./views/basic_config/feedback/index.vue'], resolve);}},
            { path: 'exchange', icon: 'android-settings', name: 'exchange', title: '兑换设置', component: resolve => {require(['./views/basic_config/exchange/index.vue'], resolve);}}
        ]
    },
    {
        path: '/appuser',
        icon: 'person',
        name: 'user',
        title: '学员管理',
        component: Main,
        children: [
            {
                path: 'list',
                icon: 'person',
                name: 'user-list',
                title: '学员列表',
                component: resolve => {require(['./views/user/list.vue'], resolve); }
            }
        ]
    },
    /* {
        path: '/access',
        icon: 'key',
        name: 'access',
        title: '权限管理',
        component: Main,
        children: [
            { path: 'index', title: '权限管理', name: 'access_index', component: resolve => { require(['./views/access/access.vue'], resolve); } }
        ]
    }, */
    {
        path: '/admin',
        icon: 'person',
        name: 'admin',
        title: '管理员管理',
        component: Main,
        children: [
            { path: 'index', name: 'admin_index', title: '管理员管理', component: resolve => { require(['./views/admin/index.vue'], resolve); } }
        ]
    },
    /* {   path: '/table',
        icon: 'person',
        title: '可编辑表格',
        component: Main,
        children: [
            {path: 'edit', name: 'edit-table', component: resolve=> { require(['./views/tables/editable-table.vue'], resolve);} }
        ]
    } */
    // {
    //     path: '/charts',
    //     icon: 'ios-analytics',
    //     name: 'charts',
    //     title: '图表',
    //     component: Main,
    //     children: [
    //         { path: 'pie', title: '饼状图', name: 'pie', icon: 'ios-pie', component: resolve => { require('./views/access/access.vue') },
    //         { path: 'histogram', title: '柱状图', name: 'histogram', icon: 'stats-bars', component: resolve => { require('./views/access/access.vue') }

    //     ]
    // },
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    preview,
    locking,
    ...appRouter,
    page500,
    page401,
    page404
];
